import React from 'react'
import { NavLink,Routes,Route,Navigate } from 'react-router-dom'
import Home from './pages/Home'
import About from './pages/About'

export default function App() {
  return (
    <div>
      <div className='row'>
        <div className='col-xs-offset-2 col-xs-8'>
          <div className='page-header'><h2>Reat Router Demo</h2></div>
        </div>
      </div>
      <div className='row'>
        <div className='col-xs-offset-2 col-xs-2'>
          <div className='list-group'>
            {/* 原始的连接 */}
            {/* <a href="" className='list-group-item active'>Home</a>
            <a href="" className='list-group-item'>About</a> */}
            {/* NavLink点击默认给样式active, 和bootstrap的active样式相同, 所以可以默认不写 */}
            {/* <NavLink className='list-group-item' to="/home">Home</NavLink>
            <NavLink className='list-group-item' to="/about">About</NavLink> */}

            <NavLink className={({isActive})=>isActive?'list-group-item activeTest':'list-group-item'} to="/home">Home</NavLink>
            <NavLink className='list-group-item' to="/about">About</NavLink>
          </div>
        </div>
        <div className='col-xs-6'>
          <div className='panel'>
            <div className='panel-body'>
              {/* 路由规则 */}
              <Routes>
                <Route path='/home' element={<Home/>} />
                <Route path='/about' element={<About/>} />
                {/* 设置默认跳转路径 */}
                <Route path='/' element={<Navigate to="/about" />} />
              </Routes>
            </div>
          </div>
        </div>
      </div>
    </div>
  )
}
